- /* sdfcosdv.cpp by K.Tsuru */
- // function ID 3207 DRADIX, reference
- /********************************************************************
- SDouble class
- trigonometric function cos x for |x| < pi/4 using the divide method
- Similar to the method using in Exp(x),x is divided into
- x = a(short number)+b(long but very small)
- and uses an addition theorem
- cos(x) = cos(a+b) = cos(a)*cos(b) - sin(a)*sin(b).
- *********************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SDouble CosDiv(const SDouble& x){
- const uint seriesFig = 4u;
- if(x.RdxExp() < -(int)seriesFig) return CosSeries(x); // |x| << 1.0
-
- SDouble a, b(x), y;
- //Make an approximation by taking out upper seriesFig figures.
- // x = a+b, cos(x) = cos(a+b) = cos(a)*cos(b) - sin(a)*sin(b)
- a = b.TakeOutFigures(seriesFig);
- b -= a;
- if( b.Sign(3207) ){
- //It gives a sufficient precision comparing with CosSeries().
- RealSize C;
- C.SetEffFig(x.EffFig() + 2u, C.TEMP_EXTEND);
- a = SinSeries(a); //a and b have same sign.
- b = SinSeries(b); //Both series can be rapidly evaluated.
- y = Sqrt((ONE - a*a)*(ONE - b*b)) - a*b;
- C.SetEffFig(0);
- } else y = CosSeries(a);
- return y;
- }
sdfcosdv.cpp : last modifiled at 2017/09/05 16:17:40(1,218 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).